from functools import reduce
import math
def intpow(s):
	return math.pow(char2num(s),3)
def char2num(s):
	return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}[s]
while True:
	str = input()
	if str!='exit':
		num = int(str)
		if num == reduce(lambda x,y:x+y,map(intpow,str)):
			print (1)
		else:
			print (0)
	else:
		break